﻿/// <reference path="turbo_common.js" />
/// <reference path="../General/Json.js" />

var $IncludeType = TA.Turbo.Common.IncludeType = {
	Script: 0,
	Style: 1
};

var $ResponseUpdatePanelInclude = TA.Turbo.Common.ResponseUpdatePanelInclude = function ResponseUpdatePanelInclude()
{
}
$ResponseUpdatePanelInclude.Inherit(BaseJsonDeserializable);

$ResponseUpdatePanelInclude.prototype.Type = 0;
$ResponseUpdatePanelInclude.prototype.Source = null;

$ResponseUpdatePanelInclude.prototype.DeserializeContent = function DeserializeContent(prShortName, value)
{
	switch (prShortName)
	{
		case "T": this.Type = value; break;
		case "S": this.Source = value; break;
	}
}

$ResponseUpdatePanelInclude.prototype.Process = function Process(existingIncludes)
{
	if (existingIncludes[this.Source] !== true)
	{
		switch (this.Type)
		{
			case $IncludeType.Script:
				var scriptTag = document.createElement("script");
				scriptTag.type = "text/javascript";
				scriptTag.src = this.Source;
				document.body.insertBefore(scriptTag, document.body.childNodes[0]);
				break;
			case $IncludeType.Style:
				var linkTag = document.createElement("LINK");
				linkTag.rel = "stylesheet";
				linkTag.href = this.Source;
				document.body.insertBefore(scriptTag, document.body.childNodes[0]);
				break;
		}
	}
}
